package com.parkcar;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import HttpUtils.HttpInfoRequest;
import util.BaseActivity;
import util.Constrants;

/**
 * Created by Administrator on 2016/3/8.
 */
public class SexChangeActivity extends BaseActivity{
    private ImageView icon_women,icon_men;
    int sex=-1;
    private HttpInfoRequest infoRequest;
    @Override
    protected void setUpui(Bundle arg0) {
        setContentView(R.layout.activity_sex_change);
        setTitle("性别选择");
        icon_men = (ImageView) findViewById(R.id.icon_men);
        icon_women = (ImageView) findViewById(R.id.icon_women);
        sex = Constrants.mInfo.getSex();
        if(sex==0){
            icon_men.setVisibility(View.VISIBLE);
        }else if(sex==1){
            icon_women.setVisibility(View.VISIBLE);
        }
    }

    @Override
    protected void updateUI(boolean isLogin) {

    }
    public void women_check(View view){
        icon_women.setVisibility(View.VISIBLE);
        icon_men.setVisibility(View.GONE);
        sex=1;
    }
    public void men_check(View view){
        icon_women.setVisibility(View.GONE);
        icon_men.setVisibility(View.VISIBLE);
        sex=0;
    }
    public void submit(View view){
        if(sex==-1){
            toast("请选择性别");
            return ;
        }
        infoRequest = new HttpInfoRequest(this,3);
        infoRequest.changeInfo("",sex,"");
        infoRequest.setmIHttpClinetListener(this);
        infoRequest.doRequest();
    }

    @Override
    public void httpSuccessListener(Bundle successMsg) {
        super.httpSuccessListener(successMsg);
        if(mBaseResult!=null){
            if(infoRequest!=null&&action.equalsIgnoreCase(infoRequest.getAction())){
                toast(mBaseResult.getStatus().getMsg());
                if(mBaseResult.getStatus().getRetCode()==0){
                    Constrants.mInfo.setSex(sex);
                    setResult(Constrants.CHANGE_SEX);
                    finish();
                }
            }
        }
    }
}
